<div style="width:100%; height:200px; overflow-x:auto; overflow-y:hidden; border:solid 1px #808080;">
<canvas id="canvas" width="11000" height="200" style="border:solid 1px #000000;"></canvas>
</div>
See console output for decoded message

<script>
var d = [540, 7980, 540, 4080, 540, 4060, 500, 4100, 500, 4140, 560, 1760, 540, 4060, 540, 1860, 520, 4140, 560, 3940, 540, 4060, 520, 1880, 540, 1940, 540, 1780, 540, 4040, 540, 1880, 540, 1940, 520, 1800, 540, 4020, 540, 1880, 520, 4160, 520, 1760, 560, 1860, 520, 1880, 520, 4160, 540, 3960, 540, 1860, 540, 4040, 520, 4160, 540, 1800, 500, 4060, 540, 4080, 500, 1980, 520, 1780, 540, 4040, 520, 4080, 520, 1940, 560, 1780, 520, 1880, 520, 1860, 540, 4060, 580];
//var d = [900, 1040, 880, 1060, 880, 980, 860, 1080, 880, 1060, 800, 1080, 840, 1060, 880, 540, 380, 1060, 340, 580, 880, 520, 380, 1080, 360, 560, 880, 580, 340, 1020, 440, 500, 860, 1100, 880, 1020, 840, 580, 380, 1000, 880, 1100, 340, 520, 860, 1120, 820, 520, 420, 1020, 860, 1040, 380, 580, 840, 560, 400, 1040, 880, 1040, 840, 1080, 800, 1100, 840, 1060, 340, 580, 880, 560, 340, 1100, 820, 1040, 880, 1060, 380, 540, 860, 540, 360, 1100, 840, 1040, 860, 1060, 340, 580, 880, 540, 420, 1020, 860, 1020, 880, 1060, 860, 1020, 420, 540, 880, 540, 340, 1060, 880, 1040, 380, 540, 900, 1000, 840, 1080, 880, 540, 400, 1040, 420, 500, 880, 1020, 900, 540, 380, 1040, 880, 1040, 840, 1080, 840, 1040, 880, 1040, 840, 1080, 860, 1040, 800, 1100, 840, 1080, 820, 1100, 380, 560, 840, 540, 340, 1100, 400, 520, 840, 1060, 920, 500, 440, 1000, 380, 540, 900, 540, 340, 1120, 840, 1020, 380, 560, 820, 600, 340, 1100, 860, 1060, 840, 1040, 380, 580, 800, 1080, 880, 560, 340, 1060, 380, 580, 880];
//var d = [560, 4060, 540, 4040, 540, 4060, 520, 4160, 520, 1780, 540, 4060, 520, 1880, 520, 4140, 540, 3980, 520, 4040, 540, 1900, 520, 1960, 520, 1780, 520, 4060, 520, 1900, 500, 1980, 500, 1800, 540, 4040, 560, 1860, 540, 4120, 540, 1780, 520, 1860, 560, 1840, 560, 4140, 540, 3940, 560, 1840, 560, 4040, 540, 4140, 560, 1760, 520, 4080, 520, 4060, 520, 1960, 540, 1760, 560, 4040, 540, 4060, 540, 1940, 520, 1780, 560, 1840, 540, 1860, 520, 4100, 580];
//var d = [1360, 1000, 1340, 1040, 1340, 1000, 1360, 1020, 560, 1000, 1360, 1020, 560, 1020, 1340, 940, 1360, 1000, 1320, 1060, 1320, 1000, 1360, 940, 580, 1040, 1320, 1020, 580, 1020, 540, 960, 560, 1020, 580, 1020, 540, 1020, 1380, 940, 1320, 980, 620, 1020, 1340, 1000, 560, 960, 1340, 1040, 1340, 1000, 580, 1000, 560, 960, 1360, 1000, 1340, 1040, 520, 1040, 560, 960, 1340, 1000, 580, 1020, 1340, 1020, 560, 960, 1340, 1000, 1360, 1000, 560, 1020, 600, 940, 1340, 1020, 580, 1000, 540, 1020, 1360];
//var d = [20, 80, 140, 960, 940, 460, 460, 480, 500, 880, 500, 480, 480, 440, 500, 460, 960, 940, 460, 480, 460, 460, 960, 460, 480, 940, 460, 480, 980, 920, 980, 360, 540, 460, 480, 960, 960, 940, 480, 460, 960, 960, 940, 980, 500, 100, 60, 40, 80, 40, 980, 960, 460, 480, 980, 420, 460, 960, 520, 80, 80, 180, 1000, 460, 480, 440, 480, 460, 480, 920, 500, 420, 580, 380, 460, 500, 480, 420, 480, 480, 460, 460, 980, 920, 500, 460, 460, 480, 440, 460, 480, 460, 980, 460, 440, 980, 940, 440, 500, 940, 960, 960, 520, 420, 480, 460, 980, 920, 940, 920, 520, 440, 500, 460, 940, 480, 540, 380, 480, 940, 460, 500, 460, 440, 500, 120, 80, 200, 460, 480, 480, 460, 480, 460, 440, 480, 940, 480, 480, 940, 940, 980, 460, 460, 100];
//var d = [60, 500, 340, 620, 320, 600, 380, 520, 400, 540, 400, 560, 340, 600, 340, 600, 340, 540, 400, 560, 400, 500, 420, 540, 420, 500, 420, 520, 400, 520, 420, 540, 400, 500, 440, 500, 460, 480, 420, 500, 460, 480, 440, 500, 440, 460, 460, 980, 940, 980, 940, 960, 940, 960, 460, 480, 940, 980, 440, 480, 940, 460, 500, 940, 460, 460, 460, 460, 500, 460, 480, 440, 980, 960, 460, 440, 480, 460, 460, 480, 480, 460, 440, 480, 960, 960, 960, 940, 460, 480, 460, 480, 460, 460, 460, 480, 460, 480, 460, 500, 440, 460, 460, 480, 480, 440, 460, 500, 460, 460, 480, 460, 460, 460, 460, 460, 480, 480, 460, 460, 480, 460, 460, 460, 500, 460, 440, 480, 460, 480, 460, 480, 460, 460, 960, 940, 500, 440, 480, 460, 480, 440, 980, 960, 460, 440, 1000, 920, 460, 460, 1000, 920, 480, 460, 960, 940, 960, 980, 460, 440, 480, 460, 980, 940, 460, 440, 500, 480, 460, 460, 460, 480, 960, 440, 480, 940, 960, 960, 460, 460, 980, 420, 500, 960, 960, 960, 940, 960, 460, 480, 480]
//var d = [100, 660, 260, 660, 320, 660, 240, 660, 280, 680, 260, 660, 280, 640, 280, 680, 260, 680, 240, 660, 300, 680, 240, 640, 300, 660, 240, 660, 280, 680, 280, 700, 260, 620, 280, 640, 280, 680, 260, 660, 280, 660, 280, 660, 240, 680, 280, 1160, 740, 1160, 760, 660, 280, 1160, 240, 740, 220, 620, 800, 1120, 320, 620, 760, 1200, 240, 700, 240, 640, 780, 1140, 300, 620, 780, 1180, 240, 660, 280, 660, 260, 680, 260, 640, 760, 700, 260, 1160, 260, 660, 260, 680, 280, 640, 780, 640, 280, 1180, 240, 680, 740, 1160, 240, 700, 760, 1140, 760, 1120, 300, 640, 280, 680, 260, 680, 260, 660, 280, 640, 780, 640, 300, 1180, 720, 1140, 280, 680, 740, 1160, 280, 680, 240, 680, 240, 640, 320, 620, 280, 720, 240, 640, 780, 660, 280, 1120, 300, 640, 760, 1180, 240, 680, 280, 640, 260, 660, 280, 680, 260, 660, 280, 660, 260, 700, 740, 620, 300, 1160, 240, 680, 260, 700, 740, 1140, 280, 680, 280, 640, 280, 700, 720, 680, 260, 640, 280, 680, 280, 680, 240];
var d = [520, 500, 420, 520, 400, 520, 440, 520, 400, 520, 400, 540, 400, 520, 440, 500, 440, 480, 440, 500, 440, 500, 460, 440, 460, 500, 420, 500, 440, 520, 420, 520, 420, 500, 460, 460, 480, 440, 480, 440, 500, 460, 480, 460, 460, 460, 480, 920, 980, 940, 960, 460, 500, 440, 500, 440, 480, 460, 480, 920, 500, 460, 500, 420, 980, 920, 980, 940, 480, 440, 500, 460, 460, 460, 960, 940, 980, 920, 500, 460, 480, 440, 480, 440, 960, 460, 520, 920, 960, 480, 480, 420, 500, 460, 480, 440, 500, 920, 480, 440, 500, 440, 500, 420, 500, 440, 500, 440, 980, 960, 440, 460, 480, 460, 500, 420, 520, 440, 480, 460, 480, 420, 500, 460, 480, 440, 500, 440, 500, 440, 480, 440, 480, 460, 980, 440, 480, 960, 960, 440, 500, 460, 460, 960, 460, 460, 500, 420, 980, 440, 500, 440, 500, 920, 960, 960, 960, 940, 980, 920, 960, 460, 500, 940, 960, 960, 460, 460, 960, 460, 480];

  var c = document.getElementById("canvas");
  var ctx = c.getContext('2d');


ctx.fillStyle = "#008";
ctx.font = "bold 15px Arial";

ctx.beginPath();
var t = 1000;
var l = 1;
//var k = 0.03;
var k = 0.05;
var k = 0.1;
var bits = "";
var all = "";
for (var i=0; i<d.length+1; i++)
{
  l = 1-(i&1);
  var x = t * k;
  var y = 190 - (1-l)*160;
  if (i==0)  
    ctx.moveTo(x, y);
  else
    ctx.lineTo(x, y);
  y = 190 - l*160;
  ctx.lineTo(x, y);

  if ( i>=d.length)
    break;


  var tx = (t + d[i]/2)*k;
  ctx.fillText(d[i]+"us", tx-25, l ? 20 : 160);

  var key = "???";
/*
  if (d[i] >= 450 && d[i] < 600)
    key = ",";
  if (d[i] >= 7500 && d[i] < 8500)
    key = "P";
  if (d[i] >= 3800 && d[i] < 4200) 
  {
    key = "1";
    bits += key;
  }
  if (d[i] >= 1600 && d[i] < 2000)
  {
    key = "0";
    bits += key;
  }
*/

/*
  if (d[i] >= 900 && d[i] < 1100)
    key = ",";
  if (d[i] >= 500 && d[i] < 700) 
  {
    key = "1";
    bits += key;
  }
  if (d[i] >= 1200 && d[i] < 1400)
  {
    key = "0";
    bits += key;
  }

*/


  if (d[i] >= 300 && d[i] < 700)
    key = i & 1 ? "L" : "H";
  if (d[i] >= 900 && d[i] < 1100)
    key = i & 1 ? "LL" : "HH";


/*
  if (!(i&1))
  {
    if (d[i] >= 200 && d[i] < 350)
      key = "H";
    if (d[i] >= 700 && d[i] < 850)
      key = "HH";
  } else
  {
    if (d[i] >= 600 && d[i] < 750)
      key = "L";
    if (d[i] >= 1100 && d[i] < 1300)
      key = "LL";
  }
*/
  all += key;
  ctx.fillText(key, tx, 100);

  t += d[i];
}

ctx.stroke();
while (all[0] == "?")
  all = all.substr(2);
console.log(all);
all += "L";

bits = "";
while (all.length >= 2)
{
  var segment = all.substr(0, 2);
  all = all.substr(2);
  if (segment == "HL")
    bits += "1";
  else
  if (segment == "LH")
    bits += "0";
  else
    bits += "?";
}

console.log("Bitstream with preamble: " + bits);

var last = 1;
var nbits = "";
for (var i =0; i<bits.length; i++)
{
  if (bits[i] == "0")
    last = 1-last;

  nbits += "" + last;
}
//bits = nbits;



while (bits[0] == "1")
  bits = bits.substr(1);

var t = "";
for (var i=0; i<bits.length; i+=4)
  t += bits.substr(i, 4) + " ";
console.log("Bitstream data: " + t);

var decoded = "";
while (bits.length >= 4)
{
  var nib = bits.substr(0, 4);
//  console.log(nib + " -> " + tohex(nib));
  decoded += tohex(nib);
  bits = bits.substr(4);
}


/*
   full oregon scientific temperature/humidity sensor frame
   af82416f1800067c55b            0.8 deg 76%
   af82416f1800067c55bc
*/

console.log("Hex: " + decoded);
if (bits != "")
  console.log("remainder = "+bits);

var temperature = decoded[11]*10 + decoded[10]*1 + decoded[9]*0.1;
if (decoded[12] != "0")
  temperature *= -1;
var humidity = decoded[14]*10 + decoded[13]*1;
console.log({oregon:{temperature:temperature, humidity:humidity}});

/*
console.log("bits = "+bits.length);
for (var i =0; i<bits.length; i+=8)
{
  var n = 0;
  for (var j=0; j<8; j++)
    if (bits[i+j] == "1")
       n += 1<<(j);
  console.log(n.toString(16));
}
*/
function tohex(nib)
{
  var q = 0;
  for (var i=0;  i<nib.length; i++)
    if (nib[i] == "1")
      q += 1<<i; 
  return q.toString(16);
}
</script>